uniEncode
Type
function
Summary
Converts a string from single-byte text to Unicode.
Syntax
the uniEncode of <stringToEncode>
uniEncode(<stringToEncode> [, <language>])
Description
Use the uniEncode function to convert single-byte characters to double-byte characters.
As of LiveCode 7.0 the uniEncode function has been deprecated. It will continue to work as in previous versions but should not be used in newcode as the existing behaviour is incompatible with the new, transparent Unicode handling (the resulting value will be treated as binary data rather than text). This function is only useful in combination with the also-deprecated uniDecode function and unicodeText field property. Instead, for converting text between encodings, use the textEncode and textDecode functions.
The uniEncode function is the inverse of the uniDecode function and inserts null bytes for Unicode compatibility. In other words, it turns single-byte characters into their double-byte equivalent.
You can use the UTF8 encoding only with the uniDecode and uniEncode functions. You cannot set an object's textFont property to use UTF-8. To display Unicode text in an object, use either "Unicode" or a language name as the second item of the object's textFont.
The format produced by the uniEncode function is processor-dependent. On "big-endian" processors, where the first byte is least significant (such as Intel and Alpha processors), the uniEncode function adds the null byte after each character. On "little-endian" processors, where the last byte is least significant (such as PowerPC processors), the uniEncode function adds the null byte before each character.
The ability to handle double-byte characters on "little-endian" processors was added in LiveCode 2.0. In previous versions, the uniEncode function always added the null byte after the character, regardless of platform.
The ability to convert language-specific encodings into Unicode text was added in LiveCode 2.0. In previous versions, the uniEncode function simply added a null byte.
Parameters
Name | Type | Description |
---|---|---|
stringToEncode | string | any string, or expression that evaluates to a string. |
language | enum | one of the following
|
Examples
uniEncode("AB") -- returns "A",null,"B",null (on Intel)
uniEncode("AB") -- returns null,"A",null,"B" (on PPC)
uniEncode(inputText,"Japanese") -- converts Shift-JIS to Unicode
Related
constant: null
control structure: function
function: format, platform, textDecode, textEncode, uniDecode
glossary: byte, function, object, property, return, Unicode
keyword: character, inverse, string
property: textFont, unicodeTitle
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile